//
//  CancleOutHolidayCell.m
//  AttendenceSys
//
//  Created by ld on 16/1/18.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "CancleOutHolidayCell.h"

@implementation CancleOutHolidayCell


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self initCell];
    }
    return self;
}

- (void)initCell
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIView* bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, [UIScreen mainScreen].bounds.size.width,Cancle_OutHolidayHeight)];
    bgView.backgroundColor = [UIColor whiteColor];
    
    _appBegEndTimeLab = [[UILabel alloc] initWithFrame:CGRectMake(15,
                                                                  10,
                                                                  [UIScreen mainScreen].bounds.size.width * 3 / 4,
                                                                  20)];
    [_appBegEndTimeLab setBackgroundColor:[UIColor clearColor]];
    _appBegEndTimeLab.font = [UIFont systemFontOfSize:15];
    [_appBegEndTimeLab setTextAlignment:NSTextAlignmentLeft];
    _appBegEndTimeLab.textColor = [UIColor blackColor];
    _appBegEndTimeLab.lineBreakMode = NSLineBreakByTruncatingTail;
    [bgView addSubview:_appBegEndTimeLab];

    _appInfoLab = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 25 - 40,
                                                            _appBegEndTimeLab.frame.origin.y,
                                                            50,
                                                            _appBegEndTimeLab.frame.size.height)];
    [_appInfoLab setBackgroundColor:[UIColor clearColor]];
    _appInfoLab.font = [UIFont systemFontOfSize:15];
    [_appInfoLab setTextAlignment:NSTextAlignmentRight];
    _appInfoLab.textColor = RGB(166, 166, 166);
    [bgView addSubview:_appInfoLab];
    
    _appTimeLab = [[UILabel alloc] initWithFrame:CGRectMake(_appBegEndTimeLab.frame.origin.x,
                                                            Cancle_OutHolidayHeight/2-5,
                                                            [UIScreen mainScreen].bounds.size.width/2,
                                                            20)];
    [_appTimeLab setBackgroundColor:[UIColor clearColor]];
    _appTimeLab.font = [UIFont systemFontOfSize:14];
    [_appTimeLab setTextAlignment:NSTextAlignmentLeft];
    _appTimeLab.textColor = RGB(166, 166, 166);
    [bgView addSubview:_appTimeLab];
    
    // 请假描述
    _msgDesc = [[UILabel alloc] initWithFrame:CGRectMake(_appTimeLab.frame.origin.x,
                                                         _appTimeLab.frame.origin.y + _appTimeLab.frame.size.height,
                                                         [UIScreen mainScreen].bounds.size.width * 3 / 4,
                                                         20)];
    _msgDesc.backgroundColor = [UIColor clearColor];
    _msgDesc.font = [UIFont systemFontOfSize:15];
    [_msgDesc setTextAlignment:NSTextAlignmentLeft];
    _msgDesc.textColor = RGB(166, 166, 166);
    [bgView addSubview:_msgDesc];
    
    // 销假
    _cancleBtn = [[UIButton alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 25 - 50,
                                                            Cancle_OutHolidayHeight - 35,
                                                            60,
                                                            20)];
    _cancleBtn.hidden = YES;
    [_cancleBtn setTitle:@"销假" forState:UIControlStateNormal];
    [_cancleBtn addTarget:self action:@selector(cancleOutHoliday:) forControlEvents:UIControlEventTouchUpInside];
    [_cancleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _cancleBtn.backgroundColor = RGB(252, 119, 62);
    [bgView addSubview:_cancleBtn];
    
    [self.contentView addSubview:bgView];
}

//销假
-(void)cancleOutHoliday:(id)sender
{
    UIButton* btn = (UIButton*)sender;
    if (_delegate && [_delegate respondsToSelector:@selector(cancleOutHoliday:)]) {
        [_delegate cancleOutHoliday:btn.tag];
    }
}

-(NSString*)appInfoForAppType:(ApproveType)appType
{
    NSString* sInfo = @"未知";
    if (Approve_YES == appType) {
        sInfo = @"已审核";
    }
    else if (Approve_NO == appType)
    {
        sInfo = @"待审核";
    }
    return sInfo;
}

@end
